package com.tjp.eight.ui.fragment.mymsg.receicezan;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/2/27.
 */
public class ReceiveZanPresenter extends BasePresenterImpl<ReceiveZanView> {
    private ZanService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(ZanService.class);

    public ReceiveZanPresenter(ReceiveZanView view) {
        attachView(view);
    }

    public void loadData(String pJson) {
        RequestBody body = AppUtils.getRequestBody(pJson);
        addSubscription(service.load(body), new SubscribeCallBack<>(new NetCallBack<ZanRModel>() {
            @Override
            public void onSuccess(ZanRModel model) {
                view.loadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.fail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
